import React,{Component} from 'react';
export default class MessageFooter extends Component{
    handleSubmit = (event)=>{
        event.preventDefault();
        let username = this.username.value;
        let content = this.content.value;
        let message = {username,content};
        this.props.addMessage(message);
        this.content.value = '';
    }
   render(){
       return (
           <div className="panel-footer">
               <form onSubmit={this.handleSubmit}>
                   <div className="form-group">
                    <label>用户名</label>
                      <input 
                      ref={inst=>this.username = inst}
                     placeholder="请输入用户名"
                     className="form-control"/>
                   </div>
                   <div className="form-group">
                     <label>内容</label>
                     <input 
                      ref={inst=>this.content = inst}
                     placeholder="请输入留言内容"
                     className="form-control"/>
                   </div>
                   <div className="form-group">
                     <input type="submit" className="btn btn-primary"/>
                   </div>
               </form>
           </div>
       )
   }
}